package com.happyclub.paul.dao;

import com.happyclub.pojo.TbUserAdvice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Auther: 魏泉琦
 * @Date: 2019/4/4 09:23
 * @Description:  意见反馈表
 */
public interface UserAdviceRepostitory  extends JpaRepository<TbUserAdvice,String> {


    /**
     *@Description: 保存用户意见反馈
     *@Author: 魏泉琦
     *@date: 2019/4/4
     */
    @Modifying
    @Query(value = "INSERT into TB_USER_ADVICE(ID,ADVICE,USER_ID,DO_STATUS,SHENHE_STATUS,CONTACT_WAY,IS_HANDLE,IS_UPPER_TRACKER,INFO_LEVEL,CREATE_TIME) VALUES(?1,?2,?3,0,0,?4,0,0,0,SYSDATE)",nativeQuery = true)
    Integer saveUserAdviceContent(String adviceId, String advice, String userId, String userTepe);


    /**
     *@Description: 根据用户意见的处理状态查询用户意见
     *@Author: 魏泉琦
     *@date: 2019/4/12
     */
    List<TbUserAdvice> findTbUserAdvicesByDoStatus(long doStatus);


    /**
     *@Description: 修改用户意见信息级别和后期跟踪
     *@Author: 魏泉琦
     *@date: 2019/4/12
     */
    @Modifying
    @Query("update TbUserAdvice ua set ua.infoLevel=?1,ua.isUpperTracker=?2 ,ua.shenHeStatus=?3 where  ua.id=?4")
    Integer updateUserAdvicesByAdviceId(long infoLovel,long isUpperTracker,long shenHeStatus,String adviceId);

}
